$(function() {
	//妞币记录
	$('#currencyLog').click(function() {
		selectMenu('currencyLog');
		findByUsernameCurrencyLog(1);
	});
	
	//积分记录
	$('#pointLog').click(function() {
		selectMenu('pointLog');
		findByUsernamePointLog(1);
	});
	
	$('#currencyLog').click();
	
	/**
	 * 选中菜单
	 * @param _id	: 菜单ID
	 */
	function selectMenu(_id) {
		$('#currencyLog').attr('class', 'btnorangebig');
		$('#pointLog').attr('class', 'btnorangebig');
		$('#' + _id).attr('class', 'btnorangebig_hover');
	}
});

//获取用户妞币记录信息
var userCurrencyPage = new Page("userCurrencyPage", findByUsernameCurrencyLog, "bodyInfo", "bodyInfoPage");
userCurrencyPage.size = 5;
userCurrencyPage.pageSizeArr = [5, 10, 15];
//设置开始字符串
userCurrencyPage.beginString = '<table><thead><tr>'
							+'<th width="30">编号</th>'
							+'<th>描叙</th>'
							+'<th width="100">妞币数</th>'
							+'<th width="120">添加时间</th>'
							+'<th width="100">操作</th></tr></thead><tbody>';
//设置结束字符串
userCurrencyPage.endString = "</tbody></table>";
//处理Page标签的函数
function findByUsernameCurrencyLog(_page) {
	if(_page != undefined) {
		userCurrencyPage.page = _page;
	}
	var _data = {
			"page" : userCurrencyPage.page,
			"size" : userCurrencyPage.size
		};
	
	jQuery.ajax({
		url : webroot + "/currency/json/findByUsernameCurrency.shtml",
		data : _data,
		type : "POST",
		dataType : "json",
		async : true,
		beforeSend: function(){
			//提交处理的函数
			userCurrencyPage.pageBeforeSend('<tr><td colspan="5">加载妞币信息中...</td></tr>');
			loading('加载妞币信息中...');
		},
		error : function(json){
			userCurrencyPage.pageError('<tr><td colspan="5">加载妞币信息出错了~</td></tr>');
			unloading();
		},
		//返回的是一个对象
		success : function(json){
			if(json.result === 'success') {
				//处理数据列表的行信息
				function getResult(obj) {
					var result = '<tr><td>' + obj.id + '</td><td>' + obj.remark + '</td><td>'
								+ obj.currency + '</td><td>' + dateUtil.getFormatDate(new Date(obj.addtime)) + '</td><td>'
								+ '--</td></tr>';
					return result;
				}
				userCurrencyPage.pageOperate(json.data, { resultFn : getResult, dataNull : '<tr><td colspan="5">没有查找到妞币信息!</td></tr>', pageFootStyle : userCurrencyPage.pageStyle.defaultStyle });
			}
			else if(json.result === 'error_not_admin') {
				alert('您不是管理员!');
			}
			else if(json.result === 'error_weibo') {
				alert(json.weiboMsg);
			}
			else if(json.result === 'error') {
				alert('请求操作, 系统出现异常!');
			}
			unloading();
		}
	});
}

//获取用户积分记录信息
var userPointPage = new Page("userPointPage", findByUsernamePointLog, "bodyInfo", "bodyInfoPage");
userPointPage.size = 5;
userPointPage.pageSizeArr = [5, 10, 15];
//设置开始字符串
userPointPage.beginString = '<table><thead><tr>'
							+'<th width="30">编号</th>'
							+'<th>描叙</th>'
							+'<th width="100">积分数</th>'
							+'<th width="120">添加时间</th>'
							+'<th width="100">操作</th></tr></thead><tbody>';
//设置结束字符串
userPointPage.endString = "</tbody></table>";
//处理Page标签的函数
function findByUsernamePointLog(_page) {
	if(_page != undefined) {
		userPointPage.page = _page;
	}
	var _data = {
			"page" : userPointPage.page,
			"size" : userPointPage.size
		};
	
	jQuery.ajax({
		url : webroot + "/point/json/findByUsernamePoint.shtml",
		data : _data,
		type : "POST",
		dataType : "json",
		async : true,
		beforeSend: function(){
			//提交处理的函数
			userPointPage.pageBeforeSend('<tr><td colspan="5">加载积分信息中...</td></tr>');
			loading('加载信息中...');
		},
		error : function(json){
			userPointPage.pageError('<tr><td colspan="5">加载积分信息出错了~</td></tr>');
			unloading();
		},
		//返回的是一个对象
		success : function(json){
			if(json.result === 'success') {
				//处理数据列表的行信息
				function getResult(obj) {
					var result = '<tr><td>' + obj.id + '</td><td>' + obj.remark + '</td><td>'
								+ obj.point + '</td><td>' + dateUtil.getFormatDate(new Date(obj.addtime)) + '</td><td>'
								+ '--</td></tr>';
					return result;
				}
				userPointPage.pageOperate(json.data, { resultFn : getResult, dataNull : '<tr><td colspan="5">没有查找到积分信息!</td></tr>', pageFootStyle : userPointPage.pageStyle.defaultStyle });
			}
			else if(json.result === 'error_not_admin') {
				alert('您不是管理员!');
			}
			else if(json.result === 'error_weibo') {
				alert(json.weiboMsg);
			}
			else if(json.result === 'error') {
				alert('请求操作, 系统出现异常!');
			}
			unloading();
		}
	});
}